import { ActionContext } from 'vuex';

const state = {
  loading: false,
  touristCount: 0,
}
export type stateType = typeof state;

const getters = {}

const mutations = {
  addTouristCount(state: stateType) {
    state.touristCount += 1;
  },
  setLoading(state: stateType, payload: boolean) {
    console.log({ payload })
    state.loading = payload
  }
}

const actions = {
  fakeFeatch({ commit }: ActionContext<stateType, unknown>): void {
    console.log('fakeFeatch 🍎1')
    commit('setLoading', true);
    console.log('fakeFeatch 🍎2')
    setTimeout(function () {
      console.log('fakeFeatch 🍎3')
      commit('addTouristCount');
      commit('setLoading', false);
    }, 3000);
  }
}

const modules = {}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions,
  modules,
}